#include <stdio.h>
struct student
{
	char name[32];
	int math;
} stu[1000];
//结构体
void xinghao( int a )
{
	int i;
	for ( i = 0 ; i < a ; i++ )
		printf("*");
	printf("\n");
}//求最后的星号

double ave( int n )
{
	int i;
	double sum = 0;
	for ( i = 0 ; i < n ; i++ )
		sum += stu[i].math;
	return sum / n;
}//求平均数

int main()
{
	int i, n, a = 0, b = 0, z = 0, x = 0, c = 0, v = 0, d = 0;
	
	do
	{
        printf("请输入班级的人数：");
		scanf("%d" , &n);
	} while ( n > 30);
	
	for ( i = 0 ; i < n ; i++ )
	{
		printf("第%d个人的姓名：" , i + 1);
		scanf("%s" , stu[i].name);
		printf("成绩为：");
		scanf("%d" , &stu[i].math);
		printf("\n");
		if ( stu[i].math < 60 ) a++;
	}
	printf("\n\n不及格人数为%d人\n分别是\n" , a);
	for ( i = 0 ; i < n ; i++ )
	{
		if ( stu[i].math < 60 ) 
			printf("%s\t" , stu[i].name);
		if ( stu[i].math >= ave(n) )
			b++;
	}
	printf("\n\n成绩在全班平均分及平均分之上的学生人数有%d人\n分别是\n" , b);
	for ( i = 0 ; i < 5 ; i++ )
	{
		if ( stu[i].math >= ave(n) )
			printf("%s\t" , stu[i].name);
	}
	printf("\n\n");
	for ( i = 0 ; i < n ; i++ )
	{
		if ( 0 < stu[i].math && stu[i].math < 60 ) z++;
		if ( 60 <= stu[i].math && stu[i].math < 69 ) x++;
		if ( 70 <= stu[i].math && stu[i].math < 79 ) c++;
		if ( 80 <= stu[i].math && stu[i].math < 89 ) v++;
		if ( 90 <= stu[i].math && stu[i].math < 100 ) d++;
	}
	printf("分数段     学生人数     图形\n");
	printf("<60       %d(%%%.2lf)     " , z , z / n * 100.0 );
	xinghao(z);
	
	printf("60-69     %d(%%%.2lf)     " , x , x / n * 100.0 );
	xinghao(x);
	
	printf("70-79     %d(%%%.2lf)     " , c , c / n * 100.0 );
	xinghao(c);
	
	printf("80-89     %d(%%%.2lf)     " , v , v / n * 100.0 );
	xinghao(v);
	
	printf(">=90      %d(%%%.2lf)     " , d , d / n * 100.0 );
	xinghao(d);
	return 0;
}